#include <bits/stdc++.h>
#define RI register int
#define CI const int&
using namespace std;
const int N=(1<<13)+5;
int n,W,g[N],f[N],x,c[N];
int main()
{
	RI i,j; for (scanf("%d%d",&n,&W),i=1;i<=n;++i) scanf("%d",&x),++c[x-1];
	int m=0; for (i=0;i<13;++i) if (c[i]>0) m|=(1<<i);
	vector <int> states; for (i=m;i;i=(i-1)&m) states.push_back(i);
	sort(states.begin(),states.end());
	for (auto x:states)
	{
		int sum=0; for (i=0;i<13;++i) if ((x>>i)&1) sum+=c[i];
		if (sum<=W) g[x]=1;
	}
	for (auto x:states)
	{
		f[x]=1e9; for  (i=x;i;i=(i-1)&x)
		if (g[i]) f[x]=min(f[x],f[x^i]+1);
	}
	return printf("%d",f[m]),0;
}
